
var user_id=$('input#user_id').attr('value');
var Pnode=$('input[name="Pnode"]').attr('value');
var Cnode=$('input[name="Cnode"]').attr('value');
$(function(){
	var json=[
	           {"name":"我的报告 " ,"isParent":"yes","icon":"fa fa-chevron-circle-down","url":""},
	           {"name":"成绩报告 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/score_analyse.js"},
	           {"name":"消费报告 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/cost_analyse.js"},
	           {"name":"借阅报告 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/book_analyse.js"},
	           {"name":"我的数据 " ,"isParent":"yes","icon":"fa fa-chevron-circle-down","url":""},
	           {"name":"基础信息 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_jbxx.js"},
	           {"name":"思政信息 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_szxx.js"},
	           {"name":"我的学籍 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_wdxj.js"},
	           {"name":"评优评奖 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_pypj.js"},
	           {"name":"勤工助学 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_qgzx.js"},
	           {"name":"我的资助 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_wdzz.js"},
	           {"name":"违纪处分 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_wjcf.js"},
	           {"name":"我的住宿 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_wdzs.js"},
	           {"name":"日常事务 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_rcsw.js"},
	           {"name":"党政信息 " ,"isParent":"no","icon":"fa fa-angle-double-right","url":"/WDDXSERVER/html/data_analyse/data_dzxx.js"}
	           
	         ];
	var length=json.length;
	var str=[];
	for(var i=0;i<length;i++){
		if(json[i].isParent=='yes')
		   str[i]='<li><span>'+json[i].name+'<i class="'+json[i].icon+'"></i></span><ul>';
		else if(i<(length-1)&&json[i].isParent=='no'){
		   if(json[i+1].isParent=='no')
		       str[i]='<li ><a href="'+json[i].url+'"><i class="'+json[i].icon+'"></i>'+json[i].name+'</a></li>';
		   else if(json[i+1].isParent=='yes')
			   str[i]='<li ><a href="'+json[i].url+'"><i class="'+json[i].icon+'"></i>'+json[i].name+'</a></li></ul></li>';
		}
		else if(i==(length-1)&&json[i].isParent=='no')
			str[i]='<li><a href="'+json[i].url+'"><i class="'+json[i].icon+'"></i>'+json[i].name+'</a></li></ul></li>';
	}
     $('ul.charts_left').append(str.join(''));
     $('ul.charts_left>li:eq('+Pnode+') ul li:eq('+Cnode+')').addClass('visited').siblings().remove('visited')
             .parents('li').addClass('selected').siblings().removeClass('selected').find('li').removeClass('visited');
	 $('ul.charts_left li ul li a').click(function(e){
            var $node=$(this);		     
		    var $this=$node.parents().addClass('visited').siblings().removeClass('visited').parents('li');
		    $this.addClass('selected').siblings().removeClass('selected').find('li').removeClass('visited');
		    e.stopPropagation();
		   // $('form[name="userid_form"]').attr('action',$node.attr('href'));
			//$('form[name="userid_form"]').submit();
		    $('div.charts_right').empty();
		    $('#change_id').attr('src',$node.attr('href'));
		    $.getScript($node.attr('href'))
		    return false;
	   });
	   $('ul.charts_left li span').click(function(e){
		   var $this=$(this).parents('li');
		//   $this.addClass('selected').siblings().removeClass('selected');
		   $(this).next().toggle();
		   
	   });
});